﻿window.GC = {
  ctx: location.origin,

  bctx: 'http://localhost:8081/',

  imgCdn: 'http://img.xxxx.com/',

  token: '',

  //判断是否是移动或是web
  browser: function () {
    var ua = navigator.userAgent;
    //var app = navigator.appVersion;
    var mobile = !!ua.match(/AppleWebKit.*Mobile.*/),
        android = ua.match(/(Android)\s+([\d.]+)/),
        ios = ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
        ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
        ipod = ua.match(/(iPod).*OS\s([\d_]+)/),
        iphone = !ipod && !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
        kindle = ua.match(/Kindle\/([\d\.]+)/), // Kindle
        weixin = ua.match(/MicroMessenger\/([^\s]+)/), // 微信
        mqq = ua.match(/QQ\/([\d\.]+)/), // 手机QQ
        mqqbrowser = ua.match(/MQQBrowser\/([\d\.]+)/), // QQ浏览器
        ucbrowser = ua.match(/UCBrowser\/([\d\.]+)/); // UC浏览器

    return {
      mobile: mobile,
      android: android,
      ios: ios,
      ipad: ipad,
      ipod: ipod,
      iphone: iphone,
      kindle: kindle,
      weixin: weixin,
      mqq: mqq,
      mqqbrowser: mqqbrowser,
      ucbrowser: ucbrowser
    };
  }(),


  /**
   * 数字格式化 若数字大于99999返回：x万，否则返回原数字
   *
   * @param num
   * @returns
   */
  formatNumber: function (num) {
    if (!num) {
      return 0;
    }
    num = parseInt(num + "");
    if (num > 99999) {
      var result = parseInt(num / 10000);
      return result + "万";
    } else {
      return num;
    }
  }
}